<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>使用JavaScript实现打印倒金字塔直线</title>
    <style type="text/css">
        div {
            text-align: center;
            line-height: 25px;
        }
    </style>

</head>
<body>

<div>
    <script>
        var t = prompt("请输入一个整数：", "");
        document.write("金字塔");
        document.write("<br>");
        if (t > 0) {
            for (var i = t; i > 0; i--) {
                for (var j = 0; j < i; j++) {
                    document.write("————");
                }
                document.write("<br>");
            }
            for (var i = 1; i < t; i++) {
                for (var j = 0; j <= i; j++) {
                    document.write("————");
                }
                document.write("<br>");
            }
        } else {
            document.write("你输入的数字不合法！");
        }
    </script>
</div>

</body>
</html>